package com.guancloud.gradesheet.view;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class ConvertFrame extends JFrame {
	public static final int CONVERT_DEFAULT_WIDTH = 300;
	
	public static final int CONVERT_DEFAULT_HEIGHT = 200;
	
	private JButton convertButton;
	
	private static final JLabel nameLabel = new JLabel("Name Colum:", SwingConstants.CENTER);
	private static final JLabel gradeLabel = new JLabel("Grade Colum:", SwingConstants.CENTER);
	private static final JLabel classLabel = new JLabel("Class Colum:", SwingConstants.CENTER);
	private static final JLabel creditLabel = new JLabel("Credit Colum:", SwingConstants.CENTER);
	private static final JLabel blankLabel = new JLabel("");
	
	private JTextField nameText = new JTextField();
	private JTextField gradeText = new JTextField();
	private JTextField classText = new JTextField();
	private JTextField creditText = new JTextField();
	
	public ConvertFrame() {

		
		Toolkit kit = this.getToolkit();
		Dimension screenSize = kit.getScreenSize();
		int curWidth = screenSize.width;			// get window width
		int curHeight = screenSize.height;			// get window height
		this.setLocation((curWidth-CONVERT_DEFAULT_WIDTH)/2, (curHeight-CONVERT_DEFAULT_HEIGHT)/2);
		
		JPanel northPanel = new JPanel();
		this.add(northPanel, BorderLayout.NORTH);
		JPanel eastPanel = new JPanel();
		this.add(eastPanel, BorderLayout.EAST);
		
		JPanel centerPanel = new JPanel();
		centerPanel.setLayout(new GridLayout(4, 2));
		centerPanel.add(nameLabel);      centerPanel.add(nameText);
		centerPanel.add(gradeLabel);	 centerPanel.add(gradeText);	
		centerPanel.add(classLabel);	 centerPanel.add(classText);	
		centerPanel.add(creditLabel);    centerPanel.add(creditText);	 
	    this.add(centerPanel, BorderLayout.CENTER);
		JPanel southPanel = new JPanel();
		
		convertButton = new JButton("Convert !");
		southPanel.add(convertButton);
		this.add(southPanel, BorderLayout.SOUTH);
		
		
		this.setSize(CONVERT_DEFAULT_WIDTH, CONVERT_DEFAULT_HEIGHT);
		Image img = kit.getImage("images/convert.png");
		this.setIconImage(img);
		
		this.setTitle("Converter");
		this.setResizable(false);
	}
}
